GBML manual / Drawing

frame

Which frame of `sprite` is shown. Reading it gives the frame on screen; a number outside 0..frame_count-1 is clamped to the nearest frame that exists (so 3 on a 2-frame sprite shows the 2nd frame).

Syntax

frame: int

Description

Which picture of sprite is showing: 0 is the first picture, 1 the second, and so on. Reading frame always gives you the picture that is on the screen right now.

You can change it whenever you like. frame = 3; shows the fourth picture. If the sprite does not have that many pictures, the last one is shown instead: write 3 on a sprite with 2 pictures and you see the 2nd one, and reading frame straight afterwards gives 1, the picture that is really showing. Anything below 0 shows the first picture. It is never an error.

frame_speed moves frame along for you, at a fixed speed, and goes back to 0 by itself after the last picture. Set frame yourself for anything driven by what is happening rather than by time: which attack picture is showing, which of eight directions to face.

Example

frame_speed = 0;
frame = 3;

Stops any animation and shows the fourth picture of the sprite, however long the animation was.

frame = (frame + 1) % frame_count;

Steps to the next picture every single game frame, wrapping back to 0 after the last one: what frame_speed = 1 does for you, written out by hand.